<%--
  Created by IntelliJ IDEA.
  User: 28064
  Date: 2022/3/19
  Time: 20:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="cal" class="com.beans.SimpleCalculator">
  <jsp:setProperty name="cal" property="*"/>
</jsp:useBean>
  
<html>
<head>
    <title>calculate</title>
</head>
<body>
<form action="calculate.jsp" method="post" name="calculate" style="font-family: 'FiraCode Nerd Font',serif;text-align: center">
  <label>
    <input type="number" name="first" style="text-align: center" value=<%=cal.getFirst()%> />
  </label>
  <label>
    <select name="operator" >
      <option value=<%=cal.getOperator()%> ><%=cal.getOperator()%></option>
      <option value="+">+</option>
      <option value="-">-</option>
      <option value="*">*</option>
      <option value="/">/</option>
    </select>
  </label>
  <label>
    <input type="number" name="second" style="text-align: center" value=<%=cal.getSecond()%>>
  </label>
<%
  try {
    float first= cal.getFirst();
    float second= cal.getSecond();
    String op = cal.getOperator();
    float result =cal.calculator();
    out.println(result);
  }catch (Exception e){
    e.printStackTrace();
  }
%>
  <br>
  <input type="submit" value="计算" style="text-align: center">
</form>
</body>
</html>
